<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>条件渲染</title>
    <script src="./js/babel.min.js"></script>
    <script src="./js/react.development.js"></script>
    <script src="./js/react-dom.development.js"></script>
    <style>
      #ad{
        height: 100px;
        background: rgb(69, 173, 199);
      }
    </style>
  </head>
  <body>
    <div id="root">

    </div>
    <script type="text/babel">
      //是否为 vip 用户
      let isVip = false;

      //虚拟 DOM 对象
      let vdom;

      //1. if...else
      // if(!isVip){
      //   vdom = <div id="ad">我是广告</div>;
      // }

      //2. 三元运算符
      // vdom = isVip ? null : <div id="ad">我是广告</div>;

      //3. 逻辑与运算符   
      vdom = !isVip && <div id="ad">我是广告</div>;

      //渲染
      ReactDOM.render(vdom, document.querySelector('#root'))

    </script>
  </body>
</html>
